﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Comm;

public partial class user_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string name = txtName.Text.Trim();
        string password = txtPassword.Text.Trim();
        string code = txtcode.Text.Trim();

        if (!txt_YanCodeImage.Equals(code))
        {
            MessageBox.Show("抱歉，验证码错误。不能让你登录。");
        }

        BLL.User bll = new BLL.User();
        Model.User user = bll.GetModelBystrWhere(string.Format(" UserName='{0}' ", name));
        if (user == null)
        {
            CnGine.Comm.MessageBox.Alert("账号或密码错误！", this.Page);
        }
        else
        {
            if (password.Equals(user.PassWord))
            {
                Session["user"] = user;
                Response.Redirect("/admin/default.aspx");
            }
            else
            {
                CnGine.Comm.MessageBox.Alert("账号或密码错误！", this.Page);
            }
        }
    }
}